/**********************************************************************************************************************
 *
 * Project:    mGameEngine
 * File:       standardmaterial.cpp
 * Author:     karooolek
 * Created on: 2009-03-14
 *
 **********************************************************************************************************************/

#include "standardmaterial.h"

namespace mGameEngine
{
namespace Graphics
{

StandardMaterial::StandardMaterial(const Color &ambient, const Color &diffuse,
        const Color &specular, float shininess, const Color &emmisive) :
        _ambient(ambient), _diffuse(diffuse),
        _specular(specular), _shininess(shininess),
        _emissive(emmisive)
{
}

StandardMaterial::~StandardMaterial()
{
}

void StandardMaterial::set() const
{
    // create and compile gpu program
    static GPUProgram gpuProgram(
#include "standardmaterial.vert"
        ,
#include "standardmaterial.frag"
        , true);

    // bind gpu program
    gpuProgram.use();

    // standard material settings
    glMaterialfv(GL_FRONT, GL_AMBIENT, _ambient);
    glMaterialfv(GL_FRONT, GL_DIFFUSE, _diffuse);
    glMaterialfv(GL_FRONT, GL_SPECULAR, _specular);
    glMaterialf(GL_FRONT, GL_SHININESS, _shininess);
    glMaterialfv(GL_FRONT, GL_EMISSION, _emissive);
}

}
}

